<template>
  <div class="list-container">
    <div class="list-item" v-for="(item, index) in obj.list" :key="index">
      <div class="list-item-content">
        <img :src="item.albums[0]" class="item-img" />
        <div class="item-bottom">
          <p class="item-title">{{item.title}}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { reactive, setup, onMounted } from "vue";
import axios from "axios";
export default {
  name: "FoodList",

  setup() {
    const obj = reactive({ list: [] });
    onMounted(() => {
      console.log("Component is mounted!");
      axios("http://127.0.0.1:3030/api/food/getFoodList", {
        method: "get",
        headers: {
          token: "123123",
        },
      })
        .then((response) => {
          return response.data;
        })
        .then((result) => {
          if (result.code == "0") {
            obj.list = result.data || [];
          }
        });
    });

    return { obj };
  },
};
</script>


<style scoped>
</style>
